#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <climits>
#define int long long 
#define x first 
#define y second 
using namespace std ;
typedef pair<int,int> PII;
const int N = 1e5 + 10;
int a[N];
PII p[N];
unordered_map<int,int> mp;//无序
int cnt = 0;
void solve()
{
     int n;
     cin >> n;
    vector<int> a(n);
    vector<int> b(n);
     for(int i = 0; i < n; i++)  cin >> a[i];
     for(int i = 0; i < n; i++)  cin >> b[i];
     for(int i = 0; i < n; i++)  mp[b[i]] ++;
   //  for(auto &c : mp) cout << c.x << " " << c.y << endl;
     for(auto &c : mp)
     {
        if(c.y == 1)
        {
            cout << "-1" << endl;
            return;
        }
        else if(c.y % 2 == 0)
        {
            cnt += c.y / 2;
        }
        else  
        {
            cnt += c.y / 2 + 1;
        }
     }
     cout << cnt << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
   // cin >> t;
    while(t -- ) solve();
    return 0;
}
